<template>

	<a-row :gutter="10" class="mb-2">
		<a-col :span="24">
			<a-card :bordered="false">
				<a-space>
					<a-input-search v-model:value="keywords" placeholder="请输入搜索条件"
						@search="tableRef.refresh(true)"></a-input-search>
				</a-space>
			</a-card>
		</a-col>
	</a-row>



	<a-row :gutter="10">
		<a-col :span="24">

			<a-card>
				<h-table ref="tableRef" height="calc(70vh)" :columns="columns" :data="queryList">

				</h-table>
			</a-card>

		</a-col>
	</a-row>


</template>

<script setup>
import processRunnerApi from "@/api/process/processRunnerApi.js";

const keywords = ref();

const tableRef = ref();

const columns = ref([

	{
		title: "tid",
		dataIndex: "tid",
	},
	{
		title: "流程名称",
		dataIndex: "processName",
	},
	{
		title: "流程版本",
		dataIndex: "processVersion",
		width: 200,
	},
	{
		title: "状态",
		dataIndex: "status",
	},
	{
		title: "开始日期",
		dataIndex: "startDate",
	},
	{
		title: "结束日期",
		dataIndex: "endDate",
	},
	{
		title: "入参",
		dataIndex: "input",
	},
	{
		title: "出参",
		dataIndex: "output",
	},
	{
		title: "操作",
		dataIndex: 'action',
		width: 300,
		fiexd: "right",
		buttonList: [
			{
				click: (field, record) => {

				},
				render: (record) => {
					return "流程";
				}
			},
			{
				type: 'primary',
				click: (field, record) => {
					edit(record)
				},
				render: (record) => {
					return "线程快照";
				}
			},
			{
				click: (field, record) => {
					stop(record)
				},
				render: (record) => {
					return "停止";
				}
			},
			{
				click: (field, record) => {
					kill(record)
				},
				render: (record) => {
					return "强制停止";
				}
			}

		]
	}
])


const queryList = async () => {
	const ds = await processRunnerApi.queryProcessRunnerInfo();
	return ds;
}

const stop = async (row) => {
	await processRunnerApi.stop({
		tid: row.tid,
		processId: row.processId,
		processVersion: row.processVersion
	});
}


const kill = async (row) => {
	await processRunnerApi.kill({
		tid: row.tid,
		processId: row.processId,
		processVersion: row.processVersion
	});
	await queryList();
}
</script>

<style scoped></style>
